package cn.consult.controller.sys.apartment;

import cn.consult.common.api.CommonPage;
import cn.consult.common.api.CommonResult;
import cn.consult.sys.entity.TDwellEmployee;
import cn.consult.sys.service.TDwellEmployeeService;
import cn.hutool.db.Page;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;


@Api(tags = "公寓管理 > 入住员工管理")
@RestController
@RequestMapping("/apartment/employee")
public class TDwellEmployeeController {


    @Autowired
    TDwellEmployeeService tDwellEmployeeService;


    @ApiOperation("getEmployeeAll =>  入住员工管理查询")
    @GetMapping("/getEmployeeAll")
    public CommonResult getEmployeeAll(@RequestParam Map<String, Object> params) {
        PageInfo<TDwellEmployee> page = tDwellEmployeeService.getEmployeeAll(params);
        return CommonResult.success(page);
    }

    @ApiOperation("addEmployee =>  添加入住员工")
    @PostMapping("/addEmployee")
    public CommonResult addEmployee(@RequestBody TDwellEmployee tDwellEmployee) {
        boolean flag = tDwellEmployeeService.saveEmployee(tDwellEmployee);
        return CommonResult.success(flag);
    }


    @ApiOperation("getEmployeeById =>  根据id查询用户")
    @GetMapping("/getEmployeeById/{id}")
    public CommonResult getEmployeeById(@PathVariable Long id) {
        TDwellEmployee byId = tDwellEmployeeService.getByIdId(id);
        return CommonResult.success(byId);
    }

    @ApiOperation("updateEmployee =>  修改用户")
    @PutMapping("/updateEmployee")
    public CommonResult updateEmployee(@RequestBody TDwellEmployee tDwellEmployee) {
        boolean flag = tDwellEmployeeService.updateEmployee(tDwellEmployee);
        return CommonResult.success(flag);
    }

    @ApiOperation("delEmployee =>  删除用户")
    @DeleteMapping("/delEmployee/{id}")
    public CommonResult delEmployee(@PathVariable Long id) {
        boolean flag = tDwellEmployeeService.removeById(id);
        return CommonResult.success(flag);
    }

    @ApiOperation("shengqing =>  公寓申请")
    @GetMapping("/shengqing/{id}")
    public CommonResult shengqing(@PathVariable Long id) {
        boolean flag = tDwellEmployeeService.shengqing(id);
        return CommonResult.success(flag);
    }


}
